function hasClass(id,cls) {
	return document.getElementById(id).className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(id, cls) {
	if(!hasClass(id,cls))
		document.getElementById(id).className += " "+cls;
	document.getElementById(id).className.replace(/ +/g,' ');
}

function removeClass(id, cls) {
	if(hasClass(id,cls)){
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		document.getElementById(id).className = document.getElementById(id).className.replace(reg,'');
	}
	document.getElementById(id).className.replace(/ +/g,' ');
}